package com.tl.juc.c1;

public class JoinThread {
    static int value = 1;

    public static void main(String[] args) throws InterruptedException {
        Thread t1= new Thread( () -> {
            try {
                Thread.sleep(2000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            value = 10;
            System.out.println("线程Runnable");
        });
        t1.start();
        // 子线程是否存活
        System.out.println(t1.isAlive());
        // 主线程等待t1子线程
        t1.join(3000);
        System.out.println(t1.isAlive());
        System.out.println("主线程:" + value);
    }
}
